home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performWireParentBase.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  9.4 KB  |  380 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  24 April 1997
  22. //
  23. //  Description:
  24. //    This script provides an option box dialog for the wireParentBase command.
  25. //
  26.  
  27. //
  28. //  Procedure Name:
  29. //      setOptionVars
  30. //
  31. //  Description:
  32. //        Initialize the option values.
  33. //
  34. //  Input Arguments:
  35. //        Whether to set the options to default values.
  36. //
  37. //  Return Value:
  38. //      None.
  39. //
  40. proc setOptionVars(int $forceFactorySettings)
  41. {
  42.     //    No option vars since users have indicated that it does not make
  43.     // sense for the node name to persist as a pref
  44.     //    
  45. }
  46.  
  47. //
  48. //  Procedure Name:
  49. //      wireParentBaseSetup
  50. //
  51. //  Description:
  52. //        Update the state of the option box UI to reflect the option values.
  53. //
  54. //  Input Arguments:
  55. //      parent               - Top level parent layout of the option box UI.
  56. //                             Required so that UI object names can be 
  57. //                             successfully resolved.
  58. //
  59. //    forceFactorySettings - Whether the option values should be set to
  60. //                             default values.
  61. //
  62. //  Return Value:
  63. //      None.
  64. //
  65. global proc wireParentBaseSetup(string $parent, int $forceFactorySettings)
  66. {
  67.     // Retrieve the option settings
  68.     //
  69.     setOptionVars ($forceFactorySettings);
  70.  
  71.     setParent $parent;
  72.  
  73.     // Query the optionVar's and set the values into the controls
  74.  
  75.     checkBoxGrp -edit -v1 0 wrSpec;
  76.     textFieldGrp -e -tx "" -enable 0 wrNode;
  77.     optionMenuGrp -e -enable 0 wrList;
  78. }
  79.  
  80. //
  81. //  Procedure Name:
  82. //      wireParentBaseCallback
  83. //
  84. //  Description:
  85. //        Update the option values with the current state of the option box UI.
  86. //
  87. //  Input Arguments:
  88. //      parent - Top level parent layout of the option box UI.  Required so
  89. //               that UI object names can be successfully resolved.
  90. //
  91. //    doIt   - Whether the command should execute.
  92. //
  93. //  Return Value:
  94. //      None.
  95. //
  96. global proc wireParentBaseCallback(string $parent, int $doIt)
  97. {
  98.     setParent $parent;
  99.  
  100.     // Set the optionVar's from the control values, and then perform the
  101.     // command
  102.     if ($doIt) {
  103.         performWireParentBase 0; 
  104.         addToRecentCommandQueue "performWireParentBase 0" "Wire Parent Base";
  105.     }    
  106. }
  107.  
  108. //
  109. //  Procedure Name:
  110. //      wireParentBaseOptions
  111. //
  112. //  Description:
  113. //        Construct the option box UI.  Involves accessing the standard option
  114. //        box and customizing the UI accordingly.
  115. //
  116. //  Input Arguments:
  117. //      None.
  118. //
  119. //  Return Value:
  120. //      None.
  121. //
  122. proc wireParentBaseOptions()
  123. {
  124.     //    Name of the command for this option box.
  125.     //
  126.     string $commandName = "wireParentBase";
  127.  
  128.     //    Build the option box actions.
  129.     //
  130.     string $callback = ($commandName + "Callback");
  131.     string $setup = ($commandName + "Setup");
  132.  
  133.     //    STEP 1:  Get the option box.
  134.     //    ============================
  135.     //
  136.     //    The value returned is the name of the layout to be used as
  137.     //    the parent for the option box UI.
  138.     //
  139.     string $layout = getOptionBox();
  140.     setParent $layout;
  141.     
  142.     //    STEP 2:  Pass the command name to the option box.
  143.     //    =================================================
  144.     //
  145.     //    Any default option box behaviour based on the command name is set 
  146.     //    up with this call.  For example, updating the 'Help' menu item with
  147.     //    the name of the command.
  148.     //
  149.     setOptionBoxCommandName("wire");
  150.     
  151.     //    STEP 3:  Activate the default UI template.
  152.     //    ==========================================
  153.     //
  154.     //    Activate the default UI template so that the layout of this 
  155.     //    option box is consistent with the layout of the rest of the 
  156.     //    application.
  157.     //
  158.     setUITemplate -pushTemplate DefaultTemplate;
  159.  
  160.     //    STEP 4: Create option box contents.
  161.     //    ===================================
  162.     //    
  163.     //    This, of course, will vary from option box to option box.    
  164.     
  165.     //    Turn on the wait cursor.
  166.     //
  167.     waitCursor -state 1;
  168.  
  169.     tabLayout -tabsVisible 0 -scrollable 1;
  170.     
  171.     string $parent = `columnLayout -adjustableColumn 1`;
  172.  
  173.     checkBoxGrp    
  174.         -numberOfCheckBoxes 1
  175.         -label "Specify Node"
  176.         -label1 ""
  177.         -v1 0 
  178.         -on1 "optionMenuGrp -e -enable 1 wrList;textFieldGrp -e -enable 1 wrNode"
  179.          -offCommand "optionMenuGrp -e -enable 0 wrList;textFieldGrp -e -enable 0 wrNode"
  180.         wrSpec;
  181.  
  182.     textFieldGrp -enable 0 -label "Wire Node" -tx "" wrNode;
  183.     // Create an option menu listing existing wires
  184.     //
  185.     optionMenuGrp -enable 0 -l "Existing Nodes"
  186.         -cc "textFieldGrp -e -tx `optionMenuGrp -q -v wrList` wrNode" wrList;
  187.  
  188.     // add all the wires to the menu
  189.     //
  190.     int $pp;
  191.     string $bnArray[];
  192.     $bnArray = `ls -type wire`;
  193.     int $bnCount = size($bnArray);
  194.     if ($bnCount > 0 ) {
  195.         for ($pp = 0; $pp < $bnCount; $pp++)
  196.         {
  197.             menuItem -l $bnArray[$pp];
  198.         }
  199.     } else {
  200.         menuItem -l "No Wires Selected";
  201.     }
  202.  
  203.     //    Turn off the wait cursor.
  204.     //
  205.     waitCursor -state 0;
  206.     
  207.     //    Step 5: Deactivate the default UI template.
  208.     //    ===========================================
  209.     //
  210.     setUITemplate -popTemplate;
  211.  
  212.     //    Step 6: Customize the buttons.  
  213.     //    ==============================
  214.     //
  215.     //    Provide more descriptive labels for the buttons.  This is not 
  216.     //    necessary, but in some cases, for example, a button labelled 
  217.     //    'Create' may be more meaningful to the user than one labelled
  218.     //    'Apply'.
  219.     //
  220.     //    Disable those buttons that are not applicable to the option box.
  221.     //
  222.     //    Attach actions to those buttons that are applicable to the option
  223.     //    box.  Note that the 'Close' button has a default action attached 
  224.     //    to it that will hide the window.  If a a custom action is
  225.     //    attached to the 'Close' button then be sure to call the 'hide the
  226.     //    option box' procedure within the custom action so that the option
  227.     //    box is hidden properly.
  228.  
  229.     //    'Apply' button.
  230.     //
  231.     string $applyBtn = getOptionBoxApplyBtn();
  232.     button -edit
  233.         -command ($callback + " " + $parent + " " + 1)
  234.         $applyBtn;
  235.  
  236.     //    'Save' button.
  237.     //
  238.     string $saveBtn = getOptionBoxSaveBtn();
  239.     button -edit 
  240.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  241.         $saveBtn;
  242.  
  243.     //    'Reset' button.
  244.     //
  245.     string $resetBtn = getOptionBoxResetBtn();
  246.     button -edit 
  247.         -command ($setup + " " + $parent + " " + 1)
  248.         $resetBtn;
  249.  
  250.     //    Step 7: Set the option box title.
  251.     //    =================================
  252.     //
  253.     setOptionBoxTitle("Parent Base Wire Options");
  254.  
  255.     //    Step 8: Customize the 'Help' menu item text.
  256.     //    ============================================
  257.     //
  258.     setOptionBoxHelpTag( "ParentBaseWire" );
  259.  
  260.     //    Step 9: Set the current values of the option box.
  261.     //    =================================================
  262.     //
  263.     eval (($setup + " " + $parent + " " + 0));    
  264.     
  265.     //    Step 10: Show the option box.
  266.     //    =============================
  267.     //
  268.     showOptionBox();
  269. }
  270.  
  271. //
  272. //  Procedure Name:
  273. //      wireParentBaseHelp
  274. //
  275. //  Description:
  276. //        Return a short description about this command.
  277. //
  278. //  Input Arguments:
  279. //      None.
  280. //
  281. //  Return Value:
  282. //      string.
  283. //
  284. proc string wireParentBaseHelp()
  285. {
  286.  
  287.     return 
  288.     "  Command: wireParentBase";
  289. }
  290.  
  291. //
  292. //  Procedure Name:
  293. //      assembleCmd
  294. //
  295. //  Description:
  296. //        Construct the command that will apply the option box values.
  297. //
  298. //  Input Arguments:
  299. //      None.
  300. //
  301. proc string assembleCmd()
  302. {
  303.     string $cmd;
  304.     
  305.     setOptionVars(false);
  306.  
  307.     $cmd = "doWireEdit";
  308.  
  309.     //    This is parent base wire mode = 5
  310.     
  311.     int $radio = 5;
  312.  
  313.     int $wrp=0;
  314.     if (`checkBoxGrp -exists wrSpec`) {
  315.         $wrp = `checkBoxGrp -query -v1 wrSpec`;
  316.     }
  317.     
  318.     string $wrn="\"\"";
  319.     if (`textFieldGrp -exists wrNode`) {
  320.         $wrn=`textFieldGrp -query -tx wrNode`;
  321.         if ($wrn=="") $wrn="\"\"";
  322.     }
  323.  
  324.     $cmd += (" " + $radio + " " + $wrp + " " + $wrn);
  325.     return $cmd;
  326. }
  327.  
  328. //
  329. //  Procedure Name:
  330. //      performWireParentBase
  331. //
  332. //  Description:
  333. //        Perform the wireParentBase command using the corresponding 
  334. //        option values.  This procedure will also show the option box
  335. //        window if necessary as well as construct the command string
  336. //        that will invoke the wireParentBase command with the current
  337. //        option box values.
  338. //
  339. //  Input Arguments:
  340. //      0 - Execute the command.
  341. //      1 - Show the option box dialog.
  342. //      2 - Return the command.
  343. //
  344. global proc string performWireParentBase(int $action)
  345. {
  346.     string $cmd = "";
  347.  
  348.     switch ($action) {
  349.  
  350.         //    Execute the command.
  351.         //
  352.         case 0:
  353.             //    Get the command.
  354.             //
  355.             $cmd = `assembleCmd`;
  356.  
  357.             //    Execute the command with the option settings.
  358.             //
  359.             eval($cmd);
  360.  
  361.             break;
  362.  
  363.         //    Show the option box.
  364.         //
  365.         case 1:
  366.             wireParentBaseOptions;
  367.             break;
  368.  
  369.         //    Return the command string.
  370.         //
  371.         case 2:
  372.             //    Get the command.
  373.             //
  374.             $cmd = `assembleCmd`;
  375.             break;
  376.     }
  377.     return $cmd;
  378. }
  379.  
  380.